package com.mei.allpowerfuladapter;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.mei.allpowerfuladapter.bean.Bean;
import com.mei.allpowerfuladapter.utils.ViewHolder;

import java.util.List;

/**
 * Created by Administrator on 2015/9/23.
 */
public class MyAdapterWithCommonViewHolder extends BaseAdapter{

    private List<Bean> mDatas;
    private Context mContext;
    private LayoutInflater inflater;

    public MyAdapterWithCommonViewHolder(Context context,List<Bean> datas){
        this.mContext=context;
        this.mDatas=datas;
        this.inflater=LayoutInflater.from(context);
    }
    @Override
    public int getCount() {
        Log.i("MainActivity","getCount="+mDatas.size());
        return mDatas.size();
    }

    @Override
    public Object getItem(int position) {
        Log.i("MainActivity","getItem="+position);
        return mDatas.get(position);
    }

    @Override
    public long getItemId(int position) {
        Log.i("MainActivity","getItemId="+position);
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder=ViewHolder.get(mContext, convertView, parent, R.layout.list_view_item, position);
        Bean bean= mDatas.get(position);
        ((TextView)holder.getView(R.id.tv_title)).setText(bean.getTitle());
        ((TextView)holder.getView(R.id.tv_desc)).setText(bean.getTitle());
        ((TextView)holder.getView(R.id.tv_time)).setText(bean.getTitle());
        ((TextView)holder.getView(R.id.tv_phone)).setText(bean.getTitle());
        return holder.getConvertView();
    }
}
